<template>
  <div>
    <ul>
      <li><router-link to="/contacts/all">All Contacts</router-link></li>
      <li><router-link to="/contacts/alice">Alice</router-link></li>
      <li><router-link to="/contacts/bob">Bob</router-link></li>
    </ul>
    <button type="button" @click="fn">随机显示</button>
    <!-- 二级路由入口 -->
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  data(){
    return{
      arr:['all','alice','bob']
    }
  },
  methods:{
    fn(){
      const i=Math.floor(Math.random()*this.arr.length)
      this.$router.push(`/contacts/${this.arr[i]}`)
    }
  }
}
</script>

<style>

</style>